package com.hjsmallfly.syllabus.room.convert

import com.hjsmallfly.syllabus.bean.LessonDetailInfo
import com.hjsmallfly.syllabus.bean.SemesterData
import com.hjsmallfly.syllabus.room.record.LessonRecord

class CreditLessonConvertor() {

    fun parse(lesson: LessonDetailInfo) = LessonRecord().apply {
        lesson.class_info.let {
            location = it.className
            cid = it.classNo.toLong()
            teather = it.teacherName
            val season = when {
                it.semester.contains("秋") -> 1
                it.semester.contains("春") -> 2
                it.semester.contains("夏") -> 3
                else -> 0
            }
            val year = it.semester.substringBefore('-', "0").toInt()
            semester = SemesterData(year, season)
        }
    }
}